package com.jzo2o.foundations.controller.consumer;

import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationTypeSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.model.dto.response.ServeSimpleResDTO;
import com.jzo2o.foundations.service.IServeService;
import com.jzo2o.foundations.service.IServeTypeService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户端 - 服务相关接口
 * @author JIAN
 */
@RestController("consumerServeController")
@RequestMapping("/customer/serve")
@Api(tags = "用户端 - 服务相关接口")
public class ServeController {
    /**
     * 获取首页服务类型及服务项
     */
    @GetMapping("/firstPageServeList")
    public List<ServeCategoryResDTO> getFirstPageServeList(@RequestParam Long regionId) {
        return serveService.getFirstPageServeList(regionId);
    }

    /**
     * 获取全部服务类型
     */
    @GetMapping("/serveTypeList")
    public List<ServeAggregationTypeSimpleResDTO> getServeTypeList(@RequestParam Long regionId) {
        return serveTypeService.getServeTypeList(regionId);
    }

    /**
     * 获取热门服务项
     */
    @GetMapping("/hotServeList")
    public List<ServeAggregationSimpleResDTO> getHotServeList(@RequestParam Long regionId) {
        return serveService.getHotServeList(regionId);
    }

    /**
     * 获取指定id的服务详情
     */
    @GetMapping("/{id}")
    public ServeAggregationSimpleResDTO getServeById(@PathVariable("id") Long serveId) {
        return serveService.getServeById(serveId);
    }

    /**
     * 服务查询
     */
    @GetMapping("/search")
    public List<ServeSimpleResDTO> findServeList(@RequestParam() String cityCode,
                                                 @RequestParam(required = false) Long serveTypeId,
                                                 @RequestParam(required = false) String keyword) {
        return serveService.findServeList(cityCode, serveTypeId, keyword);
    }

    @Resource
    private IServeService serveService;
    @Resource
    private IServeTypeService serveTypeService;
}